package com.hetao.xx.game;

import android.annotation.SuppressLint;

import com.hetao.xx.Global;
import com.hetao.xx.orm.UserVo;

import java.util.ArrayList;
import java.util.List;

public class FightUser {
    public UserVo user;
    public int timeLine;
    public boolean dead=false;
    public List<String> message;
    public FightUser(UserVo user){
        this.user = user;
        timeLine = 0;
        message = new ArrayList<>(4);
    }

    @SuppressLint("DefaultLocale")
    public List<String> fight(FightUser other) {
        message.clear();
        int hurt = (user.attack - other.user.defence);
        if (hurt < 0) {
            hurt = 0;
        }
        other.user.Hp = (other.user.Hp - hurt);
        if (other.user.Hp < 0) {
            other.user.Hp = 0;
        }
        message.add(String.format("<%s>攻击<%s>造成(%d)伤害,<%s>生命值%d",user.name, other.user.name, hurt, other.user.name, other.user.Hp));
        timeLine += user.speed;
        if (other.user.Hp <= 0) {
            other.dead = true;
            message.add(String.format("<%s>挂了", other.user.name));
        }
        return message;
    }
}
